// pages/myCoupon/myCoupon.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabs: [{
      name: "未使用"
    }, {
      name: "已使用"
    }, {
      name: "已过期"
    }],
    currentTab: 0,
    scrollTop: 0,
    list:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.load();
  },
  async load(){
    let res=await wx.util.post("yhq/datalist",{status:this.data.currentTab+2});
    this.setData({
      list:res.data
    })
  },
  getSignUrl: function(index) {
    let url = "";
    if (index == 1) {
      url = "/static/images/img_coupon_beused_3x.png"
    } else if (index == 2) {
      url = "/static/images/img_coupon_failure_3x.png"
    }
    return url;
  },
  change(e) {
    this.setData({
      currentTab:e.detail.index
    })
    this.load();
  },
  onPageScroll(e) {
    this.setData({
      scrollTop:e.detail.scrollTop
    })
  }
})